@extends('layouts.admin')

@section('title', 'User List')

@section('content')
    <div class="static-content">
        <div class="page-content">
            <ol class="breadcrumb">
                <li class=""><a href="{{url('/admin')}}">Home</a></li>
                <li ><a href="{{url('/admin/user')}}">User</a></li>
                <li class="active"><a href="{{url('/admin/user/list')}}">List</a></li>
            </ol>
            <div class="container-fluid">
                <div data-widget-group="group1">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h2>用户列表</h2>
                                </div>
                                <form class="form-group" method="get" action="{{url('/admin/user/list')}}">
                                    <label class="col-md-2 control-label">搜索</label>
                                    <div class="col-md-8">
                                        <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="fa fa-search"></i>
                                                    </span>
                                            <input type="text" class="form-control" placeholder="搜索" name="q" value="{{$q or ''}}">
                                        </div>
                                    </div>
                                </form>
                                <div class="panel-body no-padding">
                                    <div>
                                        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-fixed-header m-n" id="example">
                                            <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>名称</th>
                                                <th>邮箱</th>
                                                <th>Steam</th>
                                                <th>等级</th>
                                                <th>注册于</th>
                                                <th>最后活跃</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            @if (!empty($users))
                                                @foreach($users as $user)
                                                    @if (Auth::user()->roleLevel() > $user->roleLevel())
                                                    <tr class="gradeX" data-uid="{{$user->id}}">
                                                        <td><a href="{{url('/user/info/'.$user->id)}}" target="_blank">{{$user->id or 0}}</a></td>
                                                        <td>{{$user->name or ''}}</td>
                                                        <td>{{$user->email or ''}}</td>
                                                        <td><a href="{{$user->getSteamUser->profileurl or '#'}}" target="_blank">{{$user->getSteamUser->personaname or ''}}</a></td>
                                                        <td>{{$user->userRole->role->display_name or ''}}</td>
                                                        <td>{{$user->created_at  or ''}}</td>
                                                        <td>{{$user->last_actived_at or ''}}</td>
                                                        <td>
                                                            <a class="btn btn-success" href="{{url('/admin/user/edit?id='.$user->id)}}">编辑</a>
                                                        </td>
                                                    </tr>
                                                    @endif
                                                @endforeach
                                            @endif
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <th colspan="8">
                                                        @if (empty($q))
                                                            {{$users->links()}}
                                                        @else
                                                            {{$users->appends('q', $q)->links()}}
                                                        @endif
                                                    </th>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="{{cdn('/supervise/assets/plugins/datatables/jquery.dataTables.j')}}s"></script>
    <script src="{{cdn('/supervise/assets/plugins/datatables/dataTables.bootstrap.js')}}"></script>
    <script src="{{cdn('/supervise/assets/plugins/tables-fixedheader/js/dataTables.fixedHeader.j')}}s"></script>
    <script src="{{cdn('/supervise/assets/demo/demo-fixedheadertables.js')}}"></script>
@endsection